package com.netease.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.netease.jichu.Product;
import com.netease.service.ProductService;

@Controller
public class IndexController {
	//主页和详情显示页面
	@Autowired
	private ProductService ps;
	@RequestMapping("/")
	public String index(Model model){
		List<Product> product=ps.productAll();
		model.addAttribute("productList",product);
		return "index";
	}

	@RequestMapping(value="/show")
	public String showP(@RequestParam(value="id") int id,Model model){
		Product product=ps.getProduct(id);
		System.out.println(product.getisBuy()+""+product.getisSell());
		model.addAttribute("product",product);
//		model.addAttribute("product.title",product.getTitle());
		
		return "show";
	}
	
}
